package Excercise;

public class Ex01_Q32 {

	// 주민번호 유효성 검사
	// 123456-1234567
	// 1*2 + 2*3 + 3*4 + 4*5 + 5*6 + 6*7
	// 1*8 + 2*9 + 3*2 + 4*3 + 5*4 + 6*5

	public static void main(String[] args) {

		long jumin = 9002061345319L;

		// int key = (int) (jumin / 1000000000000L);
		// System.out.println(key);

		long key = 0;
		long total = 0;
		// 반복문으로 처리

		// System.out.println(Math.pow(10, 12));
		for (long divider = 1000000000000L, prime = 2; divider >= 10; divider /= 10, ++prime) {
			if (prime > 9)
				prime = 2;
			key = (int) (jumin / divider);
			total = total + (key * (int) prime);
			if (key > 0)
				jumin = jumin % (key * divider);

			// key = (int) (jumin / 100000000000L);
			// System.out.println(key % 10);

			// key = (int) (jumin / 10000000000L);
			// System.out.println(key - 10);

			// key = (int) (jumin / 1000000000L);
			// System.out.println(key - 100 - 20);

			// key = (int) (jumin / 100000000L);
			// System.out.println(key - 100 - 200 - 30);

			// 123456
			// 123456/10000 => 1
			// 123456 % (1*100000)=>23456

			// 23456/10000 =>2
			// 23456 % (2*10000 =>3456
			// 3456/100 => 3

			// 첫째자리수

			/*key = (int) (jumin / 1000000000000L);
			total = total + (key * 2);
			if (key > 0)
				jumin = jumin % (key * 1000000000000L);

			// 둘째자리수
			key = (int) (jumin / 100000000000L);
			total = total + (key * 3);
			if (key > 0)
				jumin = jumin % (key * 100000000000L);

			// 셋째자리수
			key = (int) (jumin / 10000000000L);
			total = total + (key * 4);
			if (key > 0)
				jumin = jumin % (key * 10000000000L);

			// 넷째자리수
			key = (int) (jumin / 1000000000L);
			total = total + (key * 5);
			if (key > 0)
				jumin = jumin % (key * 1000000000L);

			// 다섯째자리수
			key = (int) (jumin / 100000000L);
			total = total + (key * 6);
			if (key > 0)
				jumin = jumin % (key * 100000000L);

			// 여섯째자리수
			key = (int) (jumin / 10000000L);
			total = total + (key * 7);
			if (key > 0)
				jumin = jumin % (key * 10000000L);

			// 일곱째 자리수
			key = (int) (jumin / 1000000L);
			total = total + (key * 8);
			if (key > 0)
				jumin = jumin % (key * 1000000L);

			// 여덟째자리수
			key = (int) (jumin / 100000L);
			total = total + (key * 9);
			if (key > 0)
				jumin = jumin % (key * 100000L);

			// 아홉째자리수
			key = (int) (jumin / 10000L);
			total = total + (key * 2);
			if (key > 0)
				jumin = jumin % (key * 10000L);

			// 열번째자리수
			key = (int) (jumin / 1000L);
			total = total + (key * 3);
			if (key > 0)
				jumin = jumin % (key * 1000L);

			// 열한번째자리수
			key = (int) (jumin / 100L);
			total = total + (key * 4);
			if (key > 0)
				jumin = jumin % (key * 100L);

			// 열두번째자리수
			key = (int) (jumin / 10L);
			total = total + (key * 5);
			if (key > 0)
				jumin = jumin % (key * 10L);*/

			// System.out.println(total);
			
			
			System.out.println(total);
			System.out.println(jumin);
			System.out.println((11 - total % 11) % 10);

		}

	}

}